import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入elmentplus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//全局引入axios
import axios from 'axios'

const app = createApp(App);

//配置全局路径
axios.defaults.baseURL = "http://localhost:8080"
//将axios挂载到app对象上
app.config.globalProperties.$axios = axios
//跨域请求中传递cookie
axios.defaults.withCredentials = true


// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么
	console.log('响应拦截器：',response);
	if(response.data.code == 50001){
		router.push("/login");
	}
    return response;
  }, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
  });

//使用elementplus
app.use(ElementPlus).use(store).use(router).mount('#app')
